#!/bin/sh

delete_all_transient_registry()
{
	DUMPIMREG="/opt/hp/hpima/bin/dumpimreg"
	REGDIR="/var/opt/hp/hpima/registry"
	
	# Test hpima process status
	eval "ps -e -o command | grep -v grep | grep hpima 1>/dev/null 2>&1"
	SHALL_WE_GO=$?
	# 0 for agent is running
	# 1 for agent is not running
	if [ $SHALL_WE_GO -eq 1 ]
	then
		#No Agents was running, So let the massacre begin !!!
		for i in `find $REGDIR/`
		do
			if [ -f $i ]
			then
				eval "dumpimreg -q $i 1>/dev/null 2>&1"
				FILE_TYPE=$?
				# OK, like you told me, Rocky, the return value's meaning is:
				# 0: persistent registry file
				# 1: transient registry file
				# 2: NOT a registry file
				if [ $FILE_TYPE -eq 1 ]
				then
					# This type of file is really what we care
					# Now, let's get rid of it
					rm -rf $i
				fi
			fi
		done
	else
		#Agents was running, so we just quit and leave it alone
		return -1
	fi
}


delete_all_transient_registry
exit $?